#include "ethread.h"

EThread::EThread(MainWindow* parent, QStringList& files, ak_master< ak_symmetric_key > encryption_key, std::string alg, std::string mode):
		ProgressThread(files, parent)
{
	_encryption_key = encryption_key;

	_option_head.set_encryption_algorithm(alg, mode);	
}

bool EThread::job(QString &fileName) {
	 try {
		 ak_master< ak_percentage > px = new ak_percentage( NULL );
		 _encryption_key->encrypt_file_with_header( fileName.toStdString(),
                                                       _option_head, "", px );
		 return true;
  } catch( ak_error e ) {
	  QString s  = fileName + ": " + QString::fromStdString(e.message());
	  showError(s);
	  return false;
    }
}
